#ifndef DATASTREAM_H_
#define DATASTREAM_H_

#include <boost/integer.hpp>
#include <vector>
#include <string>

namespace uav
{
namespace comm
{

/**
 * @class DataStream
 * @brief Interface for reading data from and writing data to a device.
 */
class DataStream
{
public:
	/**
	 * Checks if there is any data available at the input.
	 */
	virtual bool isDataAvailable() const = 0;

	/**
	 * Reads a single byte.
	 */
	virtual uint8_t readByte() = 0;

	/**
	 * Reads the specified number of bytes into @a buffer.
	 */
	virtual void read(std::vector<uint8_t> &buffer, int numBytes) = 0;

	/**
	 * Reads a line of characters up to @e and @e including
	 * the specified terminator.
	 */
	virtual std::string readLine(char terminator = '\n') = 0;

	/**
	 * Write a single byte.
	 *
	 * @return Ture on success, false on error.
	 */
	virtual bool writeByte(uint8_t dataByte) = 0;

	/**
	 * Writes the data from the provided vector.
	 *
	 * @return Ture on success, false on error.
	 */
	virtual bool write(const std::vector<uint8_t> &buffer) = 0;

	/**
	 * Writes a string.
	 *
	 * @return Ture on success, false on error.
	 */
	virtual bool write(const std::string &str) = 0;

	virtual ~DataStream() {}
};

}
}


#endif
